package Interfaz;

import Controladores.Mesa;
import Controladores.Usuario;
import java.sql.ResultSet;
import javax.swing.JOptionPane;


public class Ventana extends Ventana_Defaults {

    ResultSet rs;
    Usuario usuario;
    public Ventana() {
        initComponents();
        usuario = new Usuario();
        setSize(1000, 600);
        setLocationRelativeTo(null);
        setResizable(false);
        setTitle("La Condesa Restaurant & Bar");
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtUsuario = new javax.swing.JTextField();
        btnAcceder = new javax.swing.JButton();
        pswContrasena = new javax.swing.JPasswordField();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 204, 204));
        setFont(new java.awt.Font("AR BERKLEY", 0, 10)); // NOI18N
        setForeground(new java.awt.Color(0, 204, 204));
        getContentPane().setLayout(null);

        jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 36)); // NOI18N
        jLabel1.setText("Contraseña:");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(200, 430, 200, 50);

        jLabel2.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 36)); // NOI18N
        jLabel2.setText("Usuario:");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(260, 370, 140, 50);

        txtUsuario.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 36)); // NOI18N
        getContentPane().add(txtUsuario);
        txtUsuario.setBounds(460, 380, 310, 40);

        btnAcceder.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 36)); // NOI18N
        btnAcceder.setText("Acceder");
        btnAcceder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAccederActionPerformed(evt);
            }
        });
        getContentPane().add(btnAcceder);
        btnAcceder.setBounds(360, 500, 250, 40);

        pswContrasena.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pswContrasenaActionPerformed(evt);
            }
        });
        getContentPane().add(pswContrasena);
        pswContrasena.setBounds(460, 440, 310, 30);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Logo bien.jpg"))); // NOI18N
        getContentPane().add(jLabel4);
        jLabel4.setBounds(0, 40, 960, 590);

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnAccederActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAccederActionPerformed
        if(usuario.login(txtUsuario.getText(), pswContrasena.getText())){
        VentanaTipoOrden ventanaTipoOrden = new VentanaTipoOrden(txtUsuario.getText());
        ventanaTipoOrden.setVisible(true);
        this.dispose();
        } else {
            JOptionPane.showMessageDialog(this, "Lo setimos usuario o contraseña incorrectos");
        }
    }//GEN-LAST:event_btnAccederActionPerformed

    private void pswContrasenaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pswContrasenaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pswContrasenaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
       

        
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ventana().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAcceder;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPasswordField pswContrasena;
    private javax.swing.JTextField txtUsuario;
    // End of variables declaration//GEN-END:variables
}
